package Excise5;

public class zuoye5 {
	public static void main(String[] args) {
		int [][] m1 = new int [5][];
		int [][] m2 = new int [5][];
		
		m1[0] = new int [5];
		m1[1] = new int [5];
		m1[2] = new int [5];
		m1[3] = new int [5];
		m1[4] = new int [5];
		m2[0] = new int [5];
		m2[1] = new int [5];
		m2[2] = new int [5];
		m2[3] = new int [5];
		m2[4] = new int [5];
		
		m1[0][0] = 1;
		m1[0][1] = 8;
		m1[0][2] = 5;
		m1[0][3] = 9;
		m1[0][4] = 3;
		m1[1][0] = 4;
		m1[1][1] = 0;
		m1[1][2] = 0;
		m1[1][3] = 9;
		m1[1][4] = 8;
		m1[2][0] = 9;
		m1[2][1] = 1;
		m1[2][2] = 3;
		m1[2][3] = 7;
		m1[2][4] = 3;
		m1[3][0] = 1;
		m1[3][1] = 3;
		m1[3][2] = 4;
		m1[3][3] = 6;
		m1[3][4] = 4;
		m1[4][0] = 9;
		m1[4][1] = 5;
		m1[4][2] = 1;
		m1[4][3] = 2;
		m1[4][4] = 2;
		m2[0][0] = 7;
		m2[0][1] = 6;
		m2[0][2] = 7;
		m2[0][3] = 9;
		m2[0][4] = 0;
		m2[1][0] = 6;
		m2[1][1] = 3;
		m2[1][2] = 8;
		m2[1][3] = 8;
		m2[1][4] = 1;
		m2[2][0] = 0;
		m2[2][1] = 0;
		m2[2][2] = 6;
		m2[2][3] = 1;
		m2[2][4] = 6;
		m2[3][0] = 7;
		m2[3][1] = 4;
		m2[3][2] = 3;
		m2[3][3] = 8;
		m2[3][4] = 6;
		m2[4][0] = 2;
		m2[4][1] = 4;
		m2[4][2] = 6;
		m2[4][3] = 3;
		m2[4][4] = 1;
		
		int[][] result = addMatrix(m1, m2);
		System.out.println("The addition of the matrices is");
		systemOut(m1, m2, result);
		
	}
	public static int[][] addMatrix(int[][] m1, int[][] m2) {
		int[][] result = new int [5][];
		result[0] = new int[5];
		result[1] = new int[5];
		result[2] = new int[5];
		result[3] = new int[5];
		result[4] = new int[5];
		for (int i = 0; i < m1.length; i++) {
			for (int j = 0; j < m1[i].length; j++) {
				result[i][j] = m1[i][j] + m2[i][j];
			}
		}
		return result;
	}
	public static void systemOut(int [][] array1, int[][] array2, int[][] array3) {
		for (int i = 0; i < array1.length; i++) {
			for (int j = 0; j < array1[i].length; j++) {
				System.out.print(array1[i][j] + " ");
		}
			if (i == 2) {
				System.out.print(" + ");
			}
			else {
			System.out.print("   ");
			}
			for (int j = 0; j < array2[i].length; j++) {
				System.out.print(array2[i][j] + " ");
		}
			if (i == 2) {
				System.out.print(" = ");
			}
			else {
			System.out.print("   ");
			}
			for (int j = 0; j < array3[i].length; j++) {
				System.out.print(array3[i][j] + " ");
		}
		System.out.println();
	}

}
}
